package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class CalcTimeAspect {
    @Pointcut("execution(* com.itheima.controller.DeptController.*(..))")
    public void pt() {
    }

    @Around("pt()")
    public Object calcTime(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("Before...");
        Object retVal = joinPoint.proceed();
        System.out.println("AfterReturning...");
        try {
            System.out.println("AfterThrowing...");
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            System.out.println("After...");
        }
        return retVal;
    }


}
